Skip to content

Build report: structured JSON report with per-mojo log capture - #12695

Draft
gnodet wants to merge 2 commits into
feature/logging-foundationfrom
feature/build-report
Draft

Build report: structured JSON report with per-mojo log capture#12695
gnodet wants to merge 2 commits into
feature/logging-foundationfrom
feature/build-report

Conversation

@gnodet

@gnodet gnodet commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Part 2 of the logging feature chain (depends on #12694 — logging foundation).

Adds a structured build report that captures per-module and per-mojo execution results, timing, log events, and failures as a JSON file at the end of every build.

15 files changed, ~2700 insertions — focused on report data model, collection, and serialization.

What's in this PR

Layer Files Description
API BuildReport, BuildStatus, ModuleReport, MojoReport, FailureReport Immutable interfaces for the report data model
Impl DefaultBuildReport, DefaultModuleReport, DefaultMojoReport, DefaultFailureReport Record implementations
Collector BuildReportCollector EventSpy that tracks lifecycle events and captures log output via LogEventSink, routing to mojo/module/build-level buffers
Writer BuildReportJsonWriter Zero-dependency JSON serializer with stable field order
Tests 3 test classes, 17 tests Unit tests for collector, JSON writer, and integration

Key design decisions

  • EventSpy pattern: BuildReportCollector is a @Named @Singleton that extends AbstractEventSpy, discovered automatically — no wiring changes needed
  • Thread-based log routing: Uses ConcurrentHashMap<Long, String> (thread ID → mojo/project key) to associate log events with the correct scope in parallel builds
  • Dual sink architecture: Uses LogEventSink (4-arg) independently from the existing LogSink (5-arg) used by ProjectBuildLogAppender — no interference with console output
  • Atomic writes: Reports are written to a temp file, then atomic-moved into place with a timestamped filename and a build-report-latest.json symlink
  • Defensive: onSessionEnded wraps report generation in try-catch so report failures never crash the build

What's NOT in this PR (deferred to later PRs)

PR chain

# PR Feature
1 #12694 Logging foundation
2 This PR Build report
3 #12697 Console modes
4 #12698 Warning mode + diagnostics
5 #12699 mvnlog viewer
#12702 Structured problems pipeline

Test plan

  • 17 new unit/integration tests pass
  • Full Maven test suite passes (same results as base branch)
  • CI validation

🤖 Generated with Claude Code

@gnodet
gnodet force-pushed the feature/logging-foundation branch from bae1db9 to 5a5af1e Compare August 8, 2026 01:19
@gnodet
gnodet force-pushed the feature/build-report branch from 602fffb to 056dcf0 Compare August 8, 2026 01:23
gnodet added a commit that referenced this pull request Aug 8, 2026
Add the --console CLI flag with four output modes:
- plain: compact one-line-per-module output for CI
- rich: JLine status bar with live reactor progress
- verbose: full mojo-level output (current default)
- machine: JSON lines for piping to external tools

Part 3 of the #12572 split (depends on build report PR #12695).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gnodet and others added 2 commits August 8, 2026 07:34
Add a structured build report that captures per-module and per-mojo
execution results, timing, log events, and failures as a JSON file
(target/build-reports/) at the end of every build.

Part 2 of the #12572 split. Builds on the logging foundation from
PR #12694 (LogEvent, LogLevel, LogEventSink).

New API interfaces:
- BuildReport: root report with metadata, modules, failures, problems
- BuildStatus: SUCCESS/FAILURE/SKIPPED enum
- ModuleReport: per-module results with mojo list
- MojoReport: per-mojo execution with captured log events
- FailureReport: exception details and stack traces

Implementation:
- BuildReportCollector: EventSpy that tracks lifecycle events and
  captures log output via LogEventSink, routing events to
  mojo/module/build-level buffers using thread-based tracking
- BuildReportJsonWriter: zero-dependency JSON serializer
- Atomic file writes with timestamped files and latest symlink
- Thread-safe for parallel builds (-T)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…in build report JSON

LogEvents from java.util.logging now include their source class name,
source method name, and thread ID in the JSON report when present.
Non-JUL events (from SLF4J/Log API) omit these fields.

Also adds writeField(long) overload and removeTrailingComma() helper
to simplify JSON serialization of optional trailing fields.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet
gnodet force-pushed the feature/build-report branch from 056dcf0 to a1ee585 Compare August 8, 2026 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant